package yl.hs.bmipfull.service.production.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yl.hs.bmipfull.daos.laboratory.IProductInfoDao;
import yl.hs.bmipfull.daos.material.IWarehouseDao;
import yl.hs.bmipfull.daos.production.IBrickShipOrderDao;
import yl.hs.bmipfull.daos.production.IBrickShipOrderDetailDao;
import yl.hs.bmipfull.daos.production.IFinishProductInventoryDao;
import yl.hs.bmipfull.daos.salemanage.ICustomerInfoDao;
import yl.hs.bmipfull.daos.salemanage.ISaleOrderPlaceDao;
import yl.hs.bmipfull.pojo.production.BrickShipOrderDetailEntity;
import yl.hs.bmipfull.pojo.production.BrickShipOrderEntity;
import yl.hs.bmipfull.pojo.production.BrickShipOrderModel;
import yl.hs.bmipfull.pojo.production.ProductionDispatchLogEntity;
import yl.hs.bmipfull.service.production.IBrickShipService;
import yl.hs.bmipfull.service.salemanage.ISaleContractService;
import yl.hs.bmipfull.utils.HsApp;
import yl.hs.bmipfull.utils.SearchFilterEngine;
import yl.hs.bmipfull.utils.Tl;
import yl.hs.bmipfull.utils.datastate.ActionType;
import yl.hs.bmipfull.viewmodels.*;
import yl.hs.bmipfull.viewmodels.finance.OrderState;
import yl.hs.bmipfull.viewmodels.finance.ShipOrderSignInfoModel;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

/*
 * BrickShipServiceImpl
 * @category
 * @author 谢景广
 * @date 2022-12-13
 */
@Service
public class BrickShipServiceImpl extends ProductionBaseService implements IBrickShipService {
    @Override
    public PageResult<BrickShipOrderEntity> queryFreightPage(PageQuery query, int rowNum, int page) {
        PageResult<BrickShipOrderEntity> result = new PageResult<>(rowNum);
        var filters = SearchFilterEngine.generateQueryList(query.getFilters(),
                BrickShipOrderEntity.class);
        result.setPage(page);
        query.getQuery().put("querySkip", (page - 1) * rowNum);
        query.getQuery().put("pageSize", rowNum);
        query.checkSortSides(BrickShipOrderEntity.class);
        query.getQuery().put("sortSide", String.join(",", query.getSortSides()));
        result.setRecords(orderDao.queryOrderCountByCondition(query.getQuery(), filters));
        result.setData(orderDao.queryOrderListByCondition(query.getQuery(), filters));
        return result;
    }

    @Override
    public Integer saveReviewOrders(SubmitModel model) {
        var reviews = Tl.parseToMapList(model.getData().get("orders"));
        var order = orderDao.findBySN(model.getSn());
        var details = detailDao.getListByOrderSN(model.getSn());
        var user = HsApp.getCurrent();
        for (var review : reviews) {
            var orderSN = review.get("sn").toString();
            if (!Tl.isEmpty(orderSN)) {
                var detailOpt = details.stream().filter(t -> orderSN.equals(t.getSn())).findFirst();
                if (detailOpt.isPresent()) {
                    var detail = detailOpt.get();
                    detail.setShipmentReviewTime(new Date());
                    assert user != null;
                    detail.setShipmentReviewUserSN(user.getUserSN());
                    detail.setShipmentReviewUserName(user.getUserName());
                    detail.setShipmentReviewQuantity(Tl.getBigDecimal(review.get("quantity")));
                    detail.setShipmentReviewVolume(Tl.getBigDecimal(review.get("volume")));
                    detail.setShipmentReviewRemark(review.get("remark") != null ? review.get("remark").toString() : "");
                    detail.setState((short) 10);
                    detail.setCommissionPrice(Tl.getBigDecimal(review.get("commissionPrice")!=null?review.get("commissionPrice"):0));
                    detail.setCommissionMoney(Tl.getBigDecimal(review.get("commissionMoney")!=null?review.get("commissionMoney"):0));
                    detail.setShipmentReviewPrice(Tl.getBigDecimal(review.get("shipmentReviewPrice")));
                    detailDao.update(detail);
                }
            }
        }
        var result = 0;
        if (details.stream().noneMatch(t -> t.getState() < 10)) {
            order.setState((short) 10);
            order.setShipmentReviewTime(new Date());
            assert user != null;
            order.setShipmentReviewUserSN(user.getUserSN());
            order.setShipmentReviewUserName(user.getUserName());
            result = orderDao.update(order);
            writeLog(ActionType.REVIEWED, order.getSn(), "", null, order.getClass());
        }
        return result;
    }

    @Override
    public Integer saveBatchReviewOrders(SubmitModel model) {
        var result = 0;
        var reviews = Tl.parseToMapList(model.getData().get("orders"));
        if (reviews.size() > 0) {
            var user = HsApp.getCurrent();
            var orderSNList = reviews.stream().map(t -> t.get("orderSN").toString()).distinct().toList();
            var orderList = orderDao.queryOrderBySnArray(orderSNList.toArray(new String[0]));
            var details = detailDao.queryDetailListBySNList(orderSNList);
            for (var s : orderSNList) {
                var orderReviews = reviews.stream().filter(t -> t.get("orderSN").equals(s)).toList();
                var orderDetails = details.stream().filter(t -> t.getOrderSN().equals(s)).toList();
                for (var r : orderReviews) {
                    var sn = r.get("sn").toString();
                    var opt = orderDetails.stream().filter(t -> t.getSn().equals(sn)).findFirst();
                    if (opt.isPresent()) {
                        var detail = opt.get();
                        detail.setShipmentReviewTime(new Date());
                        assert user != null;
                        detail.setShipmentReviewUserSN(user.getUserSN());
                        detail.setShipmentReviewUserName(user.getUserName());
                        detail.setShipmentReviewQuantity(Tl.getBigDecimal(r.get("quantity")));
                        detail.setShipmentReviewVolume(Tl.getBigDecimal(r.get("volume")));
                        detail.setShipmentReviewRemark(r.get("remark") != null ? r.get("remark").toString() : "");
                        detail.setState((short) 10);
                        detail.setShipmentReviewPrice(Tl.getBigDecimal(r.get("shipmentReviewPrice")));
                        detail.setCommissionPrice(Tl.getBigDecimal(r.get("commissionPrice")!=null?r.get("commissionPrice"):0));
                        detail.setCommissionMoney(Tl.getBigDecimal(r.get("commissionMoney")!=null?r.get("commissionMoney"):0));
                        result += detailDao.update(detail);
                    }
                }

                if (orderDetails.stream().allMatch(t -> t.getState() >= 10)) {
                    var opt = orderList.stream().filter(t -> t.getSn().equals(s)).findFirst();
                    if (opt.isPresent()) {
                        var order = opt.get();
                        order.setState((short) 10);
                        order.setShipmentReviewTime(new Date());
                        assert user != null;
                        order.setShipmentReviewUserSN(user.getUserSN());
                        order.setShipmentReviewUserName(user.getUserName());
                        orderDao.update(order);
                        writeLog(ActionType.REVIEWED, order.getSn(), "", null, order.getClass());
                    }
                }
            }
        }
        return result;
    }

    @Override
    public Integer cancelReview(String[] snArray) {
        var orders = orderDao.queryOrderBySnArray(snArray);
        var result = 0;
        for (var order : orders) {
            order.setState((short) 1);
            order.setShipmentReviewUserSN(null);
            order.setShipmentReviewUserName(null);
            detailDao.cancelReview(order.getSn());
            result += orderDao.update(order);
        }
        return result;
    }

    @Override
    public Integer cancelBatchReview(String[] snArray) {
        var orders = orderDao.queryOrderByDetailSnArray(snArray);
        var snList = Arrays.stream(snArray).toList();
        var result = 0;
        if (orders.size() > 0) {
            var orderSNList = orders.stream().map(t -> t.getSn()).toList();
            var details = detailDao.queryDetailListBySNList(orderSNList);
            for (var o : orders) {
                var orderDetails = details.stream().filter(t -> t.getOrderSN().equals(o.getSn())).toList();
                for (var d : orderDetails) {
                    if (snList.contains(d.getSn())) {
                        d.setShipmentReviewRemark(null);
                        d.setShipmentReviewTime(null);
                        d.setShipmentReviewUserSN(null);
                        d.setShipmentReviewUserName(null);
                        d.setState((short) 0);
                        d.setShipmentReviewVolume(BigDecimal.ZERO);
                        d.setShipmentReviewQuantity(BigDecimal.ZERO);
                        //d.setShipmentReviewPrice(BigDecimal.ZERO);
                        result += detailDao.update(d);
                    }
                }
                if (orderDetails.stream().anyMatch(t -> t.getState() < 10)) {
                    o.setState((short) 1);
                    o.setShipmentReviewUserSN(null);
                    o.setShipmentReviewUserName(null);
                    orderDao.update(o);
                }
            }
        }
        return result;
    }

    private void writeOrderLog(ActionType action, List<String> orderSNList, LoginUser user, String content) {
        for (String s : orderSNList) {
            var log = new ProductionDispatchLogEntity();
            log.setDataSN(s);
            log.setActionType(action.code);
            log.setTypeCode(getTypeCode(BrickShipOrderEntity.class));
            log.setHandleTime(new Date());
            var typeName = getTypeName(BrickShipOrderEntity.class);
            log.setTypeName(typeName);
            log.setUserSN(user.getUserSN());
            log.setUserName(user.getUserName());
            if (content != null) {
                log.setContent(content);
            } else {
                log.setContent(String.format("%s%s了编号为(%s)的%s信息", user.getUserName(), getActionDesc(action), s, typeName));
            }
            logDao.insertNew(log);
        }
    }

    @Override
    public Integer saveFreightReviewOrders(SubmitModel model) {
        var orderSnList = Tl.parseSNList(model.getData().get("orders"));
        if (orderSnList.size() > 0) {
            var user = HsApp.getCurrent();
            var review = false;
            if (model.getData().get("review") != null) {
                review = Boolean.parseBoolean(model.getData().get("review").toString());
            }
            assert user != null;
            var result = orderDao.updateOrderFreightReviewed(orderSnList, user.getUserSN(), user.getUserName(), review);
            if (result > 0) {
                writeOrderLog(review ? ActionType.REVIEWED : ActionType.UNREVIEWED, orderSnList, user, "完成运费审核");
            }
            return result;
        }
        return 0;
    }

    @Override
    public Integer saveSignInfo(SubmitModel submitModel) throws Exception {
        var order = detailDao.findBySN(submitModel.getSn());
        if (order != null) {
            var user = HsApp.getCurrent();
            var model = new ShipOrderSignInfoModel();
            Tl.getChangeLog(model, submitModel.getData());
            assert user != null;
            order.setSigner(user.getUserName());
            order.setSignSVG(model.getSignSVG());
            order.setSignedQuantity(model.getSignedQuantity());
            order.setSignedVolume(model.getSignedWeight());

            order.setSigningTime(model.getSigningTime());
            order.setSignWay(model.getSignWay());
            order.setSignPhotoPath(model.getSignPhotoPath());
            order.setSignRemark(model.getRemark());
            var dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            var logContent = user.getUserName() + "提交了发货单" + order.getSn() + "的签收信息：" + model.getSigner() +
                    "在" + dateFormat.format(model.getSigningTime()) + "通过" + model.getSignWay() + "签收" + model.getSignedWeight() + ",合计(" + model.getSignedQuantity() + ")";
            if (model.getNetWeight() == null) {
                model.setNetWeight(BigDecimal.valueOf(0));
            }
            if ((model.getNetWeight() != null && new BigDecimal("0.00").compareTo(model.getNetWeight()) < 0) || (model.getQuantity() != null && new BigDecimal("0.00").compareTo(model.getQuantity()) < 0)) {
                logContent += user.getUserName() + "修改了发货单" + order.getSn() + "的数量，从" + order.getQuantity() +
                        "改为" + model.getQuantity() + ",方量从" + model.getNetWeight() + "改为" + order.getSignedVolume() + "，修改原因：" + model.getRemark();
            }
            order.setShipmentReviewRemark(model.getShipmentReviewRemark());
            order.setShipmentReviewFlag(model.getFlag());
            order.setState(OrderState.SIGED.code);
            var result = detailDao.update(order);
            if (result > 0) {
                writeLog(ActionType.REVIEWED, order.getSn(), logContent, "", order.getClass());
            }
            var orderSnList = Tl.parseSNList(submitModel.getData().get("orders"));
            if (orderSnList.size() == 1) {
                order.setShipmentReviewUserName(user.getUserName());
                order.setShipmentReviewUserSN(user.getUserSN());
                order.setShipmentReviewTime(new Date());
                order.setShipmentReviewQuantity(model.getQuantity());
                order.setShipmentReviewVolume(model.getNetWeight());
                order.setState(OrderState.REVIEWED.code);
                order.setShipmentReviewPrice(model.getShipmentReviewPrice());
                detailDao.update(order);
            } else {
                saveReviewOrders(submitModel);
            }
            return result;
        }
        return 0;
    }

    @Override
    public Integer invalidOrder(String sn, String cause) {
        var order = detailDao.findBySN(sn);
        if (order != null) {
            order.setState(OrderState.INVALID.code);
            var result = detailDao.update(order);
            if (result > 0) {
                writeLog(ActionType.INVALID, sn, cause, "", order.getClass());
            }
            return result;
        }
        return 0;
    }

    @Override
    public PageResult<Object> queryOrderPage(PageQuery query, int rowNum, int page) {
        PageResult<Object> result = new PageResult<>(rowNum);
        var user = HsApp.getCurrent();
        if(user!=null){
            query.getQuery().put("types", user.getType()==null?0:user.getType());
        }
        var filters = SearchFilterEngine.generateQueryList(query.getFilters(),
                BrickShipOrderEntity.class);
        result.setPage(page);
        query.getQuery().put("querySkip", (page - 1) * rowNum);
        query.getQuery().put("pageSize", rowNum);
        query.checkSortSides(BrickShipOrderEntity.class);
        result.setRecords(orderDao.queryCountByCondition(query.getQuery(), filters));
        var data = orderDao.queryListByCondition(query.getQuery(), filters);
        List<Object>  results = new ArrayList<>();
        data.forEach(s->{
            var map = s.toMap();
            map.put("detail",detailDao.getListByOrderSN(s.getSn()));
            results.add(map);
        });
        result.setData(results);
        return result;
    }

    @Override
    public PageResult<BrickShipOrderModel> queryModelPage(PageQuery query, int rowNum, int page) {
        PageResult<BrickShipOrderModel> result = new PageResult<>(rowNum);
        var user = HsApp.getCurrent();
        if(user!=null){
            query.getQuery().put("types", user.getType()==null?0:user.getType());
        }
        var filters = SearchFilterEngine.generateQueryList(query.getFilters(),
                BrickShipOrderModel.class);

        result.setPage(page);
        query.getQuery().put("querySkip", (page - 1) * rowNum);
        query.getQuery().put("pageSize", rowNum);
        query.checkSortSides(BrickShipOrderModel.class);
        query.getQuery().put("sortSide", String.join(",", query.getSortSides()));
        result.setRecords(orderDao.queryMCountByCondition(query.getQuery(), filters));
        result.setData(orderDao.queryMPageByCondition(query.getQuery(), filters,true));
        return result;
    }

    @Override
    public List<BrickShipOrderEntity> queryOrderList(PageQuery pageQuery, int rowNum, int page) {
        pageQuery.getQuery().put("querySkip", page);
        pageQuery.getQuery().put("pageSize", rowNum);
        return orderDao.queryOrderList(pageQuery.getQuery());
    }

    @Override
    public List<BrickShipOrderModel> queryList(PageQuery pageQuery) {
        var user = HsApp.getCurrent();
        if(user!=null){
            pageQuery.getQuery().put("types", user.getType()==null?0:user.getType());
        }
        return orderDao.queryListByQuery(pageQuery.getQuery(), null);
    }

    @Override
    public List<Map<String, Object>> queryExportOrderList(PageQuery query) {
        var filters = SearchFilterEngine.generateQueryList(query.getFilters(),
                BrickShipOrderEntity.class);
        var list = orderDao.queryListByQuery(query.getQuery(), filters);
        var customerList = customerInfoDao.queryListBySnList(list.stream().map(BrickShipOrderModel::getCustomerSN).distinct().toList());
        var productList = productInfoDao.queryListBySnList(list.stream().map(BrickShipOrderModel::getProductSN).distinct().toList());
        List<Map<String, Object>> mapList = new ArrayList<>();
        if (list.size() > 0) {
            for (var b : list) {
                var item = b.toMap();
                var s = customerList.stream().filter(t -> t.getSn().equals(b.getCustomerSN())).findFirst();
                var customerBN = "";
                if (s.isPresent()) {
                    customerBN = s.get().getBillingNumber();
                }
                item.put("customerBN", customerBN);
                var productBD = "";
                var p = productList.stream().filter(t -> t.getSn().equals(b.getProductSN())).findFirst();
                if (p.isPresent()) {
                    productBD = p.get().getBillingNumber();
                }
                item.put("productBN", productBD);
                item.remove("remark");
                item.put("remark", b.getRemark() + "发货单号" + b.getOrderSN());
                item.put("amount", b.getPrice().multiply(b.getShipmentReviewVolume()));
                mapList.add(item);
            }
        }
        return mapList;
    }

    @Override
    public String saveOrder(SubmitModel model) throws Exception {
        BrickShipOrderEntity order;
        if (Tl.isEmpty(model.getSn())) {
            order = new BrickShipOrderEntity();
            Tl.getChangeLog(order, model.getData());
            order.setSn(queryNewSN(BrickShipOrderEntity.class));
            var orderplace = orderPlaceDao.findByTruckPlate(order.getTruckPlate(), 3);
            var orderplaces = orderPlaceDao.findByTruckPlate(order.getTruckPlate(), 4);
            if (orderplace == null && orderplaces == null) {
                return "车辆未派车";
            }
            order.setContractSN(orderplace!=null?orderplace.getContractSN():orderplaces.getContractSN());
            orderDao.insertNew(order);
            writeLog(ActionType.CREATE, order.getSn(), "", "", order.getClass());
        } else {
            order = orderDao.findBySN(model.getSn());
            var states = order.getState();
            var backJson = order.toJson();
            var changeLog = Tl.getChangeLog(order, model.getData());
            if(states>=order.getState() && order.getState()!=-1){
                return "已完成,请刷新";
            }
            var contract = contractService.findBySn(order.getContractSN());
            if(contract!=null){
                order.setLinkerName(contract.getPrintTitle()
                );
                order.setContractUnit(contract.getContractingUnit());
                order.setSalerName(contract.getSalerName());
                var user = userDao.findBySN(contract.getSalerSN());
                if (user != null) {
                    order.setSalerPhone(user.getMobileNum());
                }
            }
            writeLog(ActionType.UPDATE, order.getSn(), changeLog, backJson, order.getClass());
            var details = Tl.parseToMapList(model.getData().get("details"));
            List<BrickShipOrderDetailEntity> ens = new ArrayList<>();
            if (details.size() > 0) {
                detailDao.deleteDetailsByOrderSN(order.getSn());
                for (var i = 0; i < details.size(); i++) {
                    var orderDetail = new BrickShipOrderDetailEntity();
                    Tl.getChangeLog(orderDetail, details.get(i));
                    orderDetail.setOrderSN(order.getSn());
                    if (i == 0) {
                        orderDetail.setSn(queryNewSN(BrickShipOrderDetailEntity.class));
                    } else {
                        var sn = queryNewSN(BrickShipOrderDetailEntity.class);
                        var entitysn = String.format("%04d", Integer.parseInt(sn.substring(sn.length() - 4)) + i);
                        orderDetail.setSn(sn.substring(0, sn.length() - 4) + entitysn);
                    }
                    var inventory = finishProductInventoryDao.findByProductSN(orderDetail.getProductSN(), orderDetail.getPackageName(), orderDetail.getPackageSn());
                    if (inventory.size() > 0) {
                    } else {
                        return "库存不足，请查看库存";
                    }
                    ens.add(orderDetail);
                }
                if (order.getOutTime() == null && order.getState() == 1 && order.getPrintCount() <= 1) {
                    order.setOutTime(new Date());
                }
            }
            for (BrickShipOrderDetailEntity en : ens) {
                detailDao.insertNew(en);
            }
            orderDao.update(order);
            if (order.getState() == 1) {
                var place = orderPlaceDao.findByTruckPlate(order.getTruckPlate(), 4);
                if (place != null) {
                    place.setState((short) 5);
                    place.setShiporder(order.getSn());
                    orderPlaceDao.update(place);
                }
            }
        }
        return "成功";
    }

    @Autowired
    ISaleOrderPlaceDao orderPlaceDao;

    @Override
    public PageInfo<TrayStatisticsVO> trayStatistics(PageQuery query, int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        return new PageInfo(orderDao.trayStatistics(query.getQuery()));
    }

    @Override
    public BrickShipOrderEntity findByTruckPlate(String truckPlate, int state) {
        return orderDao.findByTruckPlate(truckPlate, state);
    }

    @Override
    public PageResult<BrickShipOrderModel> queryModelPageByContractListSN(PageQuery query, int rowNum, int page) {
        PageResult<BrickShipOrderModel> result = new PageResult<>(rowNum);
        var filters = SearchFilterEngine.generateQueryList(query.getFilters(),
                BrickShipOrderModel.class);

        result.setPage(page);
        try {
            var list = getConstructionContractSN();
            query.getQuery().put("contractListSN", list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        query.getQuery().put("querySkip", (page - 1) * rowNum);
        query.getQuery().put("pageSize", rowNum);
        query.checkSortSides(BrickShipOrderModel.class);
        query.getQuery().put("sortSide", String.join(",", query.getSortSides()));
        result.setRecords(orderDao.queryMCountByCondition(query.getQuery(), filters));
        Boolean hasProductName = Boolean.FALSE;
        for (Map<String, Object> filter : filters) {
            if ((filter.get("field") + "").contains("productName")) {
                filter.put("field", " brick_ship_order_details.productName = ");
                hasProductName = Boolean.TRUE;
            }
        }
        result.setData(orderDao.queryMPageByCondition(query.getQuery(), filters, hasProductName));
        return result;
    }

    @Override
    public Integer updatePrinCount(String sn) {
        var order = orderDao.findBySN(sn);
        writeLog(ActionType.UPDATE, sn, "打印了发货单", "", order.getClass());
        return orderDao.updatePrinCount(sn);
    }

    @Override
    public Integer restoreOrder(String sns) {
        var snlist = sns.split(",");
        for (String s : snlist) {
            var ss = orderDao.findBySN(s);
            if(ss!=null){
                if(ss.getOutTime()==null){
                    ss.setState((short) 0);
                    writeLog(ActionType.UPDATE, s, "恢复了发货单", "", ss.getClass());
                    orderDao.update(ss);
                }else{
                    ss.setState((short) 1);
                    var entity = orderDao.update(ss);
                    writeLog(ActionType.UPDATE, s, "恢复了发货单", "", ss.getClass());
                    if(entity!=null){
                        var detail = detailDao.getListByOrderSN(s);
                        detail.forEach(d->{
                            d.setState((short)0);
                            detailDao.update(d);
                        });
                    }
                }
            }
        }
        return 1;
    }

    @Override
    public Integer updateWeight(String sn, BigDecimal weight) {
        try{
        var order = detailDao.findBySN(sn);
        if(order!=null){
            Integer page = order.getQuantity().multiply(BigDecimal.valueOf(1000)).divide(order.getVolume()).intValue();
            order.setQuantity(order.getQuantity().subtract(weight));
            order.setVolume(order.getVolume().subtract(weight.multiply(BigDecimal.valueOf(1000)).divide(BigDecimal.valueOf(page))));
            writeLog(ActionType.UPDATE, order.getOrderSN(),"进行了退货操作，退货产品:"+order.getProductName()+",退货数量:"+weight+"顿", "", order.getClass());
            return detailDao.update(order);
        }
        return 0;
    }catch (Exception ee){
            return -1;
        }
    }

    @Override
    public BrickShipOrderEntity findBySN(String sn) {
        return orderDao.findBySN(sn);
    }

    @Override
    public List<BrickShipOrderDetailEntity> getDetailByOrderSN(String orderSN) {
        return detailDao.getListByOrderSN(orderSN);
    }

    @Autowired
    public void setOrderDao(IBrickShipOrderDao orderDao) {
        this.orderDao = orderDao;
    }

    @Autowired
    public void setDetailDao(IBrickShipOrderDetailDao detailDao) {
        this.detailDao = detailDao;
    }

    @Autowired
    public void setCustomerInfoDao(ICustomerInfoDao customerInfoDao) {
        this.customerInfoDao = customerInfoDao;
    }

    @Autowired
    public void setProductInfoDao(IProductInfoDao productInfoDao) {
        this.productInfoDao = productInfoDao;
    }

    @Autowired
    public void setFinishProductInventoryDao(IFinishProductInventoryDao finishProductInventoryDao) {
        this.finishProductInventoryDao = finishProductInventoryDao;
    }

    @Autowired
    public void setWarehouseDao(IWarehouseDao warehouseDao) {
        this.warehouseDao = warehouseDao;
    }

    private ICustomerInfoDao customerInfoDao;
    private IProductInfoDao productInfoDao;
    private IBrickShipOrderDao orderDao;
    private IBrickShipOrderDetailDao detailDao;
    private IFinishProductInventoryDao finishProductInventoryDao;
    private IWarehouseDao warehouseDao;
    @Autowired
    private ISaleContractService contractService;
}
